package com.aisile.wemedia.controller.v1;

import com.aisile.apis.wemedia.WmUserControllerApi;
import com.aisile.model.media.pojos.WmUser;
import com.aisile.wemedia.service.WmUserService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Auther:yry
 * @Date:2024/1/2 0002
 * @VERSON:1.0
 */
@RestController
@RequestMapping("/api/v1/wmuser")
public class WmUserController implements WmUserControllerApi {

    @Autowired
    private WmUserService wmUserService;

    @GetMapping("/findByName/{name}")
    @Override
    public WmUser findByName(@PathVariable("name") String name)  {


//        try {
//            Thread.sleep(1100);
//        }catch (Exception e){
//            e.printStackTrace();
//        }
        return wmUserService.getOne(Wrappers.<WmUser>lambdaQuery().eq(WmUser::getName,name));
    }

    @PostMapping("/save")
    @Override
    public WmUser save(@RequestBody WmUser wmUser) {
        wmUserService.save(wmUser);
        return wmUser;
    }
}
